import request from '@/utils/request'
import { makeQueryParamsSafe } from '@/utils/kris_utils'

// 获取排班列表
export function patrolPlans(queryParams) {
  return request({
    url: `/v1/patrol/classes/list${makeQueryParamsSafe(queryParams)}`,
    method: 'GET'
  })
}

// 获取某个排班的详情
export function patrolPlan(id) {
  return request({
    url: `/v1/patrol/classes/${id}`,
    method: 'GET'
  })
}

// 创建排班
export function createPatrolPlan(data) {
  return request({
    url: '/v1/patrol/classes/create',
    method: 'POST',
    data
  })
}

// 修改排班
export function updatePatrolPlan(data) {
  return request({
    url: '/v1/patrol/classes/update',
    method: 'PUT',
    data
  })
}

// 删除排班
export function deletePatrolPlan(id) {
  return request({
    url: `/v1/patrol/classes/del?id=${id}`,
    method: 'DELETE'
  })
}

// 获取巡防小组列表
export function patrolGroups(query) {
  return request({
    url: `/v1/watchman/admin/group`,
    method: 'GET',
    params: query
  })
}

// 获取巡防组类型
export function patrolGroupTypes() {
  return request({
    url: `/v1/watchman/admin/type`,
    method: 'GET'
  })
}

// 创建巡防小组
export function createPatrolGroup(data) {
  return request({
    url: `/v1/watchman/admin/group`,
    method: 'POST',
    data
  })
}

// 获取不在巡防组里的用户
export function availableMembers(queryParams) {
  return request({
    url: `/v1/watchman/admin/person${makeQueryParamsSafe(queryParams)}`,
    method: 'GET'
  })
}

// 删除巡防小组
export function deletePatrolGroup(queryParams) {
  return request({
    url: `/v1/watchman/admin/group${makeQueryParamsSafe(queryParams)}`,
    method: 'DELETE'
  })
}

// 获取巡防小组详情
export function patrolGroupDetails(id) {
  return request({
    url: `/v1/watchman/admin/group/${id}`,
    method: 'GET'
  })
}

// 修改巡防小组
export function updatePatrolGroup(queryParams) {
  return request({
    url: `/v1/watchman/admin/group${makeQueryParamsSafe(queryParams)}`,
    method: 'PUT'
  })
}

// 获取特殊日期列表
export function particularDates(queryParams) {
  return request({
    url: `/v1/patrol/special/list${makeQueryParamsSafe(queryParams)}`,
    method: 'GET'
  })
}

// 获取特殊日期详情
export function particularDate(id) {
  return request({
    url: `/v1/patrol/special/${id}`,
    method: 'GET'
  })
}

// 创建特殊日期
export function createParticularDate(data) {
  return request({
    url: 'v1/patrol/special/create',
    method: 'POST',
    data
  })
}

// 删除特殊日期
export function deleteParticularDate(id) {
  return request({
    url: `/v1/patrol/special/del?id=${id}`,
    method: 'DELETE'
  })
}

// 修改
export function editParticularDate(queryParams) {
  return request({
    url: `/v1/patrol/special/update${makeQueryParamsSafe(queryParams)}`,
    method: 'PUT'
  })
}

// 获取打卡记录（管理员）
export function clockInRecords(queryParams) {
  return request({
    url: `/v1/watchman/admin/notes${makeQueryParamsSafe(queryParams)}`,
    method: 'GET'
  })
}
